class Stack:
    def __init__(self):
        self.stack=[]

    def push(self,ele):
        self.stack.append(ele) # 添加元素到末尾

    def pop(self):
        return self.stack.pop() # 删除末尾元素，也就是把后进的先出

    def top(self):
        if self.empty():
            return 'stack is empty'
        return self.stack[-1] # -1代表列表的末尾元素，也就是栈顶元素

    def empty(self):
        return self.stack==[]

    def size(self):
        return len(self.stack)


class Queue:
    def __init__(self):
        self.queue=[]

    def enqueue(self,ele):
        self.queue.append(ele)

    def dequeue(self):
        self.queue.pop(0)

    def gethead(self):
        return self.queue[0]

    def empty(self):
        return self.queue==[]


if __name__ == '__main__':
    # 栈
    # stack1 = Stack()
    # stack1.push(1)
    # stack1.push(2)
    # stack1.push(3)
    # stack1.push(4)
    # print(stack1.stack)
    # print(stack1.pop())
    # print(stack1.stack)
    # print(stack1.size())

    # 队列
    queue1=Queue()
    queue1.enqueue(1)
    queue1.enqueue(2)
    queue1.enqueue(3)
    queue1.enqueue(4)
    print(queue1.queue)
    print(queue1.gethead())
    queue1.dequeue()
    print(queue1.queue)
    print(queue1.empty())